var status = -1;
var selectionLog = [];

function start() {
    action(1, 0, 0)
}

function action(f, c, b) {
    if (im.getServerName().equals("BMS单机") && im.getServerName().equals("BMS至尊体验服") && !im.getServerName().equals("BMS至尊")) {
        im.playerMessage(1, " 使用环境异常，请还原服务端配置。");
        im.dispose();
        return
    }
    if (status == 0 && f == 0) {
        im.dispose();
        return
    }(f == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            if (!im.isQuestFinished(58927) && im.getQuestStatus(58914) > 0 || !im.isQuestFinished(58940) && im.getQuestStatus(58928) > 0 || !im.isQuestFinished(58968) && im.getQuestStatus(58941) > 0) {
                im.sendNormalTalk_Illus_II("你还没结束在比睿山副本的调查。", 9130103, 5, false, true, 9130106)
            } else {
                if (im.isQuestFinished(58927) && im.isQuestFinished(58940) && im.isQuestFinished(58968)) {
                    im.sendNormalTalk_Illus_II("你已经不需要它了。", 9130103, 5, false, true, 9130106);
                    im.gainItem(2432732, -1);
                    im.dispose()
                } else {
                    im.sendNormalTalk_Illus_II("你不能使用原来的技术，所以你的力量会变弱很多…… ", 9130103, 5, false, true, 9130106)
                }
            }
        } else {
            if (status === a++) {
                if (!im.isQuestFinished(58927) && im.getQuestStatus(58914) > 0 || !im.isQuestFinished(58940) && im.getQuestStatus(58928) > 0 || !im.isQuestFinished(58968) && im.getQuestStatus(58941) > 0) {
                    im.playerMessage(5, "前往比睿山副本。");
                    im.gainItem(2432732, -1);
                    im.dispose();
                    im.warp(811000099, 0, false);
                    var d = im.getNumberFromQuestCustomData(58900);
                    if (d == 1) {
                        im.getPlayer().makeSkillPet()
                    }
                    im.mapleHeroBecomeNpc(d, 1)
                } else {
                    im.sendNormalTalk_Illus_II("当然，你或者剑斗、神那都一样。冒险岛世界的剑斗和神那来到这里后，都变了很多。", 9130103, 5, true, true, 9130106)
                }
            } else {
                if (status === a++) {
                    im.sendNormalTalk_Illus_II("比睿山的剑斗、神那和冒险岛世界的剑斗、神那是不一样的。", 9130103, 5, true, true, 9130106)
                } else {
                    if (status === a++) {
                        im.sendNormalTalk_Illus_II("那你要变成谁呢？你可得好好选择，变身了之后就必须以那个模样去比睿山调查了。", 9130103, 5, true, true, 9130106)
                    } else {
                        if (status === a++) {
                            im.sendNormalTalk_Illus_II("调查结束后可以再次变身，但是调查途中是不能变身的。", 9130103, 5, true, true, 9130106)
                        } else {
                            if (status === a++) {
                                var e = "你要变成谁呢？#b";
                                if (!im.isQuestFinished(58940)) {
                                    e += "\r\n#L0#剑斗 #l"
                                }
                                if (!im.isQuestFinished(58968)) {
                                    e += "\r\n#L1#神那 #l"
                                }
                                if (!im.isQuestFinished(58927)) {
                                    e += "\r\n#L2#菖蒲 #l"
                                }
                                im.askMenu(e, 1, 9130103)
                            } else {
                                if (status === a++) {
                                    if (selectionLog[status] == 0) {
                                        im.askYesNo_Illus_II("真的要变成剑斗吗？", 9130103, 1, 9130106)
                                    } else {
                                        if (selectionLog[status] == 1) {
                                            im.askYesNo_Illus_II("真的要变成神那吗？", 9130103, 1, 9130106)
                                        } else {
                                            im.askYesNo_Illus_II("真的要变成我吗？", 9130103, 1, 9130106)
                                        }
                                    }
                                } else {
                                    if (status === a++) {
                                        if (selectionLog[status - 1] == 0) {
                                            im.forceStartQuest(58900, "0");
                                            im.forceStartQuest(58915, "2");
                                            im.sendNormalTalk_Illus_II("现在开始，在比睿山副本你就变成剑斗了。", 9130103, 5, false, true, 9130106)
                                        } else {
                                            if (selectionLog[status - 1] == 1) {
                                                im.forceStartQuest(58900, "1");
                                                im.forceStartQuest(58915, "3");
                                                im.sendNormalTalk_Illus_II("现在开始，在比睿山副本你就变成神那了。", 9130103, 5, false, true, 9130106)
                                            } else {
                                                im.forceStartQuest(58900, "2");
                                                im.forceStartQuest(58915, "1");
                                                im.sendNormalTalk_Illus_II("现在开始，在比睿山副本你就变成我了。", 9130103, 5, false, true, 9130106)
                                            }
                                        }
                                    } else {
                                        if (status === a++) {
                                            im.playerMessage(5, "前往比睿山副本。");
                                            im.gainItem(2432732, -1);
                                            im.dispose();
                                            im.warp(811000099, 0, false);
                                            var d = im.getNumberFromQuestCustomData(58900);
                                            if (d == 1) {
                                                im.getPlayer().makeSkillPet()
                                            }
                                            im.mapleHeroBecomeNpc(d, 1)
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
};